package cc.permission.repository;

import cc.permission.domain.User;
import cc.permission.infrastructure.UserTunnel;
import cc.permission.infrastructure.impl.UserMysqlTunnel;

import java.util.List;

/**
 * 描述:用户仓库，支持查询用户，新增，删除，修改用户
 *
 * @author wangyan
 * @date 2020/4/3
 */
public class UserRepository {

    private UserTunnel tunnel;

    public void save(User user){
        tunnel = new UserMysqlTunnel();
        tunnel.save(user);
    }

    public void update(User user){
        tunnel = new UserMysqlTunnel();
        tunnel.update(user);
    }

    public User get(int nid){
        tunnel = new UserMysqlTunnel();
        return tunnel.get(nid);
    }

    public List<User> query(){
        tunnel = new UserMysqlTunnel();
        return tunnel.query();
    }
}
